package com.wanxi.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/d")
public class DefaultServlet extends HttpServlet {
    public String username = "";

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setCharacterEncoding("UTF-8");
        username = "粟鹏a";
        System.out.println(username + "++++++++++");
        req.setAttribute("username", username);
        req.getRequestDispatcher("/default.jsp").forward(req, resp);
//        resp.getWriter().println("<!DOCTYPE html>\n");
//        resp.getWriter().println("<html lang=\"en\">\n");
//        resp.getWriter().println("<head>\n");
//        resp.getWriter().println("    <meta charset=\"UTF-8\">\n");
//        resp.getWriter().println("    <title>Title</title>\n");
//        resp.getWriter().println("</head>\n");
//        resp.getWriter().println("<body>\n");
//        resp.getWriter().println("" + username + "\n");
//        resp.getWriter().println("</body>\n");
//        resp.getWriter().println("</html>");
    }
}
